package com.farm.equipment;

import com.farm.equipment.states.IdleState;

public abstract class Equipment {
    protected String id;
    protected String name;
    protected EquipmentState state;
    protected double fuelLevel;
    protected String location;

    public Equipment(String id, String name) {
        this.id = id;
        this.name = name;
        this.state = new IdleState();
        this.fuelLevel = 100.0;
        this.location = "未分配";
    }

    public abstract void work();
    public abstract void stop();
    
    public void setState(EquipmentState state) {
        this.state = state;
        System.out.println(name + " 状态变更为: " + state.getClass().getSimpleName());
    }

    public void setFuelLevel(double fuelLevel) {
        this.fuelLevel = fuelLevel;
        System.out.println(name + " 油量更新为: " + fuelLevel + "%");
    }

    public void setLocation(String location) {
        this.location = location;
        System.out.println(name + " 位置更新为: " + location);
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public EquipmentState getState() {
        return state;
    }

    public double getFuelLevel() {
        return fuelLevel;
    }

    public String getLocation() {
        return location;
    }

    @Override
    public String toString() {
        return "Equipment{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", state=" + state +
                ", fuelLevel=" + fuelLevel +
                ", location='" + location + '\'' +
                '}';
    }
}